由买买提看人间百态

topics

全部话题 - 话题: n
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
h**********i
发帖数: 183
1
“EnverEnver Karakas”adlı Facebook hesabında kısa süre &#
246;nce paylaşılan bir habere göre, yıllar boyunca Tü
rkiye’de saklanan “Doğu Türkistan İslami Hareketi” terör
örgütü elebaşı Abdulkadir Yapçan 31 Ağustos’ta T
ürk polisi tarafından tutuklandı. Bu hesapta yer alan haberde Yap
çan’ın “Çin’in baskısı” nedeniyle Türkiye’de
yakalandığı iddia edildi.
Yurt dış&... 阅读全帖
h****8
发帖数: 49
2
极浅显编序号常识凸显有序号数n>一切整数
——重大错误:正整数集N无上界
黄小宁(广州市华南师大南区9-303邮编510631)
将正整数集N的所有数n都配上序号,1=第1号数,…,n=第n号数,所用序号数n的
全体组成T。显然没有与N的任何元n相配号的T外无穷大序号数n>无穷集N的一切n才能与
N外的负整数配上序号,例如“-1=第n号数”中的n>N的一切n——极浅显序号常识推翻
了“N无上界”思想牢笼。
数学规定各正整数n都有相反数-n,但没规定各序号数n都有相反的序号数(与号字
结合在一起的“n号”中的n称为序号数。序号的起始号是1号,没有第-1号等,即n号没
有相反的-n号。)。可见序号数n与正整数n是有区别的。因为N的各元n都有两个对应数
±n且所有对应数组成整数集Z,所以Z的元比N的元多一倍。显然T外序号数n>N的一切n
才能定量描述Z包含多少个元素。可见“个数多少”并非都能由正整数n表示,正如正方
形对角线长等须用无理数表示,有理数全体远远不够用一样。
获中国教育学会一等奖的文献[1]论证了N内有最大自然数n′使比n′大的n′+1等
不∈N!显然没有此重大发现就绝无本文的发
h****8
发帖数: 49
3
极浅显编序号常识凸显有序号数n>一切整数0
极浅显编序号常识凸显有序号数n>一切整数
——重大错误:正整数集N无上界
黄小宁(广州市华南师大南区9-303邮编510631)
将正整数集N的所有数n都配上序号,1=第1号数,…,n=第n号数,所用序号数n的
全体组成T。显然没有与N的任何元n相配号的T外无穷大序号数n>无穷集N的一切n才能与
N外的负整数配上序号,例如“-1=第n号数”中的n>N的一切n——极浅显序号常识推翻
了“N无上界”思想牢笼。
数学规定各正整数n都有相反数-n,但没规定各序号数n都有相反的序号数(与号字
结合在一起的“n号”中的n称为序号数。序号的起始号是1号,没有第-1号等,即n号没
有相反的-n号。)。可见序号数n与正整数n是有区别的。因为N的各元n都有两个对应数
±n且所有对应数组成整数集Z,所以Z的元比N的元多一倍。显然T外序号数n>N的一切n
才能定量描述Z包含多少个元素。可见“个数多少”并非都能由正整数n表示,正如正方
形对角线长等须用无理数表示,有理数全体远远不够用一样。
获中国教育学会一等奖的文献[1]论证了N内有最大自然数n′使比n′大的n′+1
f*c
发帖数: 687
4
replace x by y^{n(n+1)},
left=[n+1-y^{n(n+1)}][y^{n+1}-y^n]+1-y^n
=(y-1)[ny^n+y^n(1-y^{n(n+1)})-1-y-...y^{n-1}]
<(y-1)[n(y^n-1)+y^n(1-y^{n(n+1)})]
=(y-1)[n(y^n-1)-y^n(y^n-1)(1+y^n+...+(y^n)^n)]
<(y-1)[n(y^n-1)-y^n(y^n-1)(n+1)]
<=0.
嘿嘿嘿,这个是n是正整数的情形。
c****p
发帖数: 6474
5
来自主题: JobHunting版 - 计算组合数C(m,n)
#include
#include
int C(int m, int n)
{
int *A, *B;
int tmp;
int i, j, k;
if((m <=0 ) || (n <=0 ))
return -1;
if(n == 1)
return m;
if(n == m)
return 1;
if(m - n < n)
n = m - n;

A = malloc(n*sizeof(int)); // A = {m, m - 1, .... m - n + 1}
B = malloc((n-1)*sizeof(int)); // B = {2, 3, ... n}
for(i = 0; i {
A[i] = m - i;
B[i] = i + 2;
}
A[n-1] = m - n + 1;
//i ... 阅读全帖
D*********t
发帖数: 745
6
来自主题: WaterWorld版 - pīnyīn wénzì zhēnde nàme bùkān ma?
这东西本来就可以随便转换的,反过来拼音转汉字就有点难了吧
wǒ mén yào gǎn xiè qín shǐ huáng hé diàn nǎo . gǎn xiè qín sh
ǐ huáng , shì yīn wéi tā tǒng yī le wén zì ; gǎn xiè diàn nǎo
, shǐ hàn zì de shū rù bǐ pīn yīn ( bāo kuò yīng yǔ ) shū rù
kuài le jǐ bèi ( rú diàn nǎo zhè gè cí de wǔ bǐ shì JNET, pīn y
īn shì diannao ) diàn nǎo shǐ wǒ mén de wén zì chéng le shì jiè
shàng zuì yōu xiù de wén zì .
zǎo zài shàng shì jì , wǒ guó jiù zài yùn niàng qǔ xiāo hàn z
ì shí xíng wén zì lā dīng huà , zhè xiàng gōng chéng shì hěn j
ù d
j********e
发帖数: 1192
7
来自主题: JobHunting版 - google scramble string O(n) 解法
我没有说字符集相同就能scramble,字符集相同是必要条件,而不充分。
我的做法是,先找到一个位置i在s1,j在s2使得分割后的4个字符串两两
有相同的字符集(i=j 或者i=N-j)。然后接着对这2对字符串继续做同样
的事情连寻找分割位置。这样递归下去,如果有某对字符串无法找到分割
位置,则表示失败。否则,最后分隔最小的字符串只有一个字符。就可以
判断scramble成功。
问题是,如果有多个分割位置,是否任选一个都可以?如果必须测试每个可能的分割位置,那复杂度就不好说了。
下面是我的简单实现代码,通过了leetcode的online judge (包括judge large)。这段代码中会处理所有可能的分割位置。如果只选第一个可能的分割位置,有一个测试失败了。
#include
#include
#include
#include
using namespace std;
#define BITMAP_LEN 256
bool compare_char_set(const char *s1, con... 阅读全帖
f*****e
发帖数: 2992
8
来自主题: JobHunting版 - N queen problem 很难想啊
nqueen leetcode 20ms 算慢还是快?nqueen II 300ms
class Solution {
public:
void f(int n, int j, int *p1, int *p2, int *p3, vector >&
vvs){
for(int i = 0; i < n; i++){
if( p1[i] < j || p2[j + i] < j || p3[n - 1 + j - i ] < j) continue;
else {
p1[i] = j;
p2[j + i] = j;
p3[n - 1 + j - i] = j;
if(j == n - 1){
vector vs(n);
string temp(n,'.');
for(int k = 0; k < n; k++){
temp[k] = 'Q';
... 阅读全帖
l****z
发帖数: 29846
9
House Foreign Affairs Committee chairwoman Rep. Ileana Ros-Lehtinen
acknowledged Tuesday that legislation aimed at making U.S. funding to the
United Nations contingent on reforms lacks bipartisan support but said it
was important to make a stand for “the principles that we believe in.”
As she prepares to mark up her bill in committee, Ros-Lehtinen (R-Fla.)
faces mounting opposition from the Obama administration and advocacy groups
supportive of deeper U.S. engagement with the U.N.
The U.N. Trans... 阅读全帖
H*****u
发帖数: 1766
10
长贴汇总,有兴趣的、自己开丰田的人自己做功课。我以前开过丰田,现在没有,以后
买车当然会考虑丰田(以及别的所有的车厂)。
发信人: Enrica (艾米), 信区: Automobile
标 题: 色老师要说这几个视频是假的吧
发信站: BBS 未名空间站 (Sat Mar 17 16:27:11 2018, 美东)
https://youtu.be/hMwXvoGhH0k
https://youtu.be/wMoaafMTl44
发信人: HeiGuGu (黑姑姑), 信区: Automobile
标 题: Re: 色老师要说这几个视频是假的吧
发信站: BBS 未名空间站 (Sat Mar 17 18:31:29 2018, 美东)
你还真有时间跟偏执狂较劲。
严格说这种视频并不能复制所有unintended acceleration的情况,因为(以我的了解
)有些UA不排除是软件原因。我之所以敢说“至少对于传统换挡杆来说换N档有效”,
是因为我几年前开丰田的时候就认真查过这个问题,翻了几百个网页。前2天又随便
google了一下来确认(自己查toyota unintended... 阅读全帖
a********e
发帖数: 53
11
来自主题: JobHunting版 - 请教n queen 问题的time complexity
这种用dfs的时间复杂度,总是绕不清楚。
code如下,
分析时间复杂度哪种比较对?
一种是dfs一共执行了n!次,每次有n^2, 所以总共是O(n!n^2).
另一种是T(n)= nT(n-1) + n^2, 所以是? 我也不知道了。
////////////////////////////////////
bool PosOK(int col[], int idx){
for ( int i=0; i< idx; i++){
if (col[i]== col[idx] || (idx-i)== abs(col[idx] - col[i] ) )
return false;
}
return true;
}
void dfs2(int col[], int idx, vvs & res, int n){
//when there is a solution
if (idx==n){
string s(n, '.');
vs tmp(n, s);
for (int i=0; i< n; i++)
tmp[i][co... 阅读全帖
o****e
发帖数: 80
12
来自主题: BrainTeaser版 - 还是扔鸡蛋,N层楼M个鸡蛋咋办啊
i think for the case of 3 eggs, should be like this
start from n-th floor, then try middle floor of n/2-th , then use the 3rd
egg to try either upper half section
or lower half section,
so for the n-th floor, the max try will be (n+2)/2;
then go to the n-2 th floor, the max try will be n/2
and so on
so the sequence will be like this
n, n-2, n-4, n-6, ......... until 4 th floor,
in total n+(n-2)+(n-4)+...+4=n(n+2)/4-2
if we want to test 100 floors, then n(n+2)/4-2>=100 -----> n=20
so for 100
d****n
发帖数: 1637
13
来自主题: Programming版 - 计算组合数C(m,n)
/*working with larger numbers but still die */
/**C(80, 20) is okay, which was not ok in previous version**/
#include
#include
#include
float
gammln (float xx)
//Returns the value ln[Ãxx)] for xx > 0.
{
//Internal arithmetic will be done in double precision, a nicety that
//you can omit if five-figure
//accuracy is good enough.
double x, y, tmp, ser;
static double cof[6] = { 76.18009172947146, -86.50532032941677,
24.01409824083091, -1.231739572450155,
... 阅读全帖
d****n
发帖数: 1637
14
来自主题: Programming版 - 计算组合数C(m,n)
/*working with larger numbers but still die */
/**C(80, 20) is okay, which was not ok in previous version**/
#include
#include
#include
float
gammln (float xx)
//Returns the value ln[Ãxx)] for xx > 0.
{
//Internal arithmetic will be done in double precision, a nicety that
//you can omit if five-figure
//accuracy is good enough.
double x, y, tmp, ser;
static double cof[6] = { 76.18009172947146, -86.50532032941677,
24.01409824083091, -1.231739572450155,
... 阅读全帖
j**l
发帖数: 2911
15
来自主题: Mathematics版 - 求H(m, n)的通项公式?
有点像Catalan数
n是整数,且n >= 0
递推关系
H(1, n) = n + 1
H(m, n) = H(m - 1, n) + H(m - 1, n - 1) + H(m - 1, n - 2) + ... + H(m - 1,
0),
也就对H(m - 1, n - i)进行累加,其中i从0到n
显然,
H(2, n) = (n + 1) + n + (n - 1) + ... + 1 = (n + 2) * (n + 1) / 2
如果m = 3,非递归的公式如何?
如果m = 4呢?
B*********h
发帖数: 800
16
☆─────────────────────────────────────☆
jiahe (JiaHe) 于 (Tue May 15 11:43:09 2007) 提到:
以前的讨论不知道有没有O(log(n))的定论。
下面是我的解法,请指正。
robertt的解答大家可以找到,O(m+n)
不过这里是 n*n 的 square matrix
1. $A_{i,i} 2. if $A_{i,i} 3. if $x > A_{i+1,i+1}$, $x\in A\\A_{[i+1,n],[i+1,n]}$
4. if $A_{i,i} 5. searching for $i$ is $O(log(n))$, search in $[i,n]$ is also $O(log(n))$.
3 log(n) in total.
☆────────────────────────────────
s*******u
发帖数: 35
17
Let f_1(n) be the number of floors we can test with 1 egg and n throws.
f_2(n) be the number of floors we can test with 2 eggs and n throws.
f_3(n) be the number of floors we can test with 3 eggs and n throws.
Clearly, f_1(n)=n; Consider two eggs. Clearly the first throw has to be at
floor n because otherwise if the
egg breaks at n, we would not be able to test the floors below. Now if the
first egg does not break, we can
test f_2(n-1) more floors. So f_2(n)=n+f_2(n-1); Hence f_2(n)=(n+1
j********8
发帖数: 10
18
来自主题: JobHunting版 - find kth element in n*n sorted matrix
//Best first search, time complexity O(klog(n)). The size of heap is at most
2*n. Every time an element is popped from the heap or inserted to the heap,
O(log(n)). We need to do the pop and insert operations k times. So the time
complexity is O(klog(n)).
//Space complexity O(n), because there are at most 2*n nodes in the priority
queue.
struct node
{
int index;
int val;
node(int index_, int val_): index(index_), val(val_){}
bool operator > (const node& other) const
{
... 阅读全帖
j********8
发帖数: 10
19
来自主题: JobHunting版 - find kth element in n*n sorted matrix
//Best first search, time complexity O(klog(n)). The size of heap is at most
2*n. Every time an element is popped from the heap or inserted to the heap,
O(log(n)). We need to do the pop and insert operations k times. So the time
complexity is O(klog(n)).
//Space complexity O(n), because there are at most 2*n nodes in the priority
queue.
struct node
{
int index;
int val;
node(int index_, int val_): index(index_), val(val_){}
bool operator > (const node& other) const
{
... 阅读全帖
d*z
发帖数: 150
20

其实要求任意矩阵的(一个)平方根也不难:

X^2=A
首先我们可以通过相似变换,使得A=P*diag{A1,A2,..,A(t)}*P^(-1)
其中A(i)=a(i) I + N
其中I是单位阵,N={n(i,j)}, 其中n(i,j)在i=j+1时为1,其他情况为0,
其中I和N都是k阶阵(当然对于不同的小方阵k可能不同)
所以N^k=0.
也就是将A分解为其Jordan标准行。
现在,我们只要能够对每一个A(i)求出一个平方根X(i),那么就有
X=P*diag{X1,X2,...,X(t)}*P^(-1)了
假设X(i)=x0*I+x1*N+x2*N^2+...+x(k-1)*N^(k-1)
由X(i)^2=(x0*I+x1*N+...+x(k-1)*N^(k-1))^2 = A(i)=a(i)I+N
我们可以通过解上面的k元二次方程组依次计算出x0,x1,... (要注意利用N^k=0)
于是我们就可以得到A的一个平方根了。
o***s
发帖数: 42149
21
电视剧《甄嬛传》火了一年 原来我们全都叫错了
甄嬛 应该念成zhen xuān
由孙俪、陈建斌等主演的电视剧《甄嬛传》可以说从年初火到了年末,就连现在,黑龙江卫视和东方卫视依然每天播出;而目前在台湾地区,每天也播出长达9小时。谁要是不会两句“那是极好的”,可就真OUT了。不过,《咬文嚼字》说,其实我们都把甄嬛的名字念错了,不是叫“zhen huán”,而该叫做“zhen xuān”。
几亿人念错“甄嬛”
日前,《咬文嚼字》编辑部公布了“2012年十大语文差错”,其中包含了一些常读错的字,《甄嬛传》的“嬛”字也险些入围,只因这个字的日常实用性不高而躲过了。据《咬文嚼字》的总编郝铭鉴介绍,专家们认为,“甄嬛”的“嬛”字在这部电视剧里应该读“xuān”而不是“huán”。不过随着《甄嬛传》的热播,观众们口口相传,已经有几亿国人把这个字念错了。
“嬛”字其实三种读音
郝铭鉴认为,从剧情看,剧中甄嬛,刚出场参加选秀,轮到她时,自报闺名“甄嬛”。皇帝问她是哪个“嬛”。甄嬛答:是“嬛嬛一袅楚宫腰”的“嬛”。皇帝说:那是取自宋代蔡伸的词,并赞美她:“‘柔桡嬛嬛,妩媚姌袅。’你果然当得起这个名字!”可见... 阅读全帖
f***y
发帖数: 4447
22
https://laoyaoba.com/html/news/newsdetail?source=pc&news_id=742044
疫情对中芯国际影响几何?没有EUV也能做到N+2?
Oliver·12:01·本土IC 来源: 爱集微
集微网消息(文/Oliver),2月14日上午,在中芯国际2019第四季度电话财报会议中,
联合CEO梁孟松博士和赵海军博士谈到了新冠肺炎对于公司的影响,并介绍了N+1和N+2
工艺的进展情况。
赵海军博士表示,公司的战略就是要与不断变化的市场保持一致 ,公司已经为下一个
阶段的成长做好了准备,“相信中芯国际将在 2020年展现出新的面貌,因为我们在技
术开发上的努力将转化为生产和收入。”
赵海军博士还代表中芯国际向武汉和其他受疫情影响城市的人们表示慰问,此前,中芯
国际已经捐款1000万元用于支持疫情防控工作。同时,中芯国际已采取相关紧急措施来
保障员工的健康和安全。基于目前的客户反馈,赵海军博士对中芯国际今年的健康成长
持乐观态度。
关于疫情的影响,赵海军博士指出,疫情对业务和收入产生负面是肯定的事情。这个时
候所有人都不能对疫情带来的整体影响有一... 阅读全帖
l****z
发帖数: 29846
23
By Patrick Goodenough
June 4, 2012
(CNSNews.com) – U.N. Secretary-General Ban Ki-moon addressed the advisory
board of a newly-established U.N. Counter-Terrorism Center in Saudi Arabia
on Sunday but was silent on the world body’s enduring failure to come up
with a universal definition of terrorism.
For well over a decade, the biggest single obstacle preventing a U.N.
agreement on defining terrorism has been the insistence by Muslim states
belonging to the Organization of Islamic Cooperation (OIC)... 阅读全帖
l******a
发帖数: 14
24
来自主题: JobHunting版 - find kth element in n*n sorted matrix
Divid the matrix to 2 by 2. Each are n/2 X n/2
If k<=n*n/4, restrain search to only the top left square
Else if k =>n*n*3/4 restrain search to only the right bottom square
Else restrain search to top right and bottom left square
This way you cut it at least to half size each time
T(n) = 2T(n/2) O(1)
So T(n) = O(nlogn)

O(n) is doable. But I need O(n lgn) and the code.O(n) algorithmhttp://www.cse.yorku.ca/~........
l******a
发帖数: 14
25
来自主题: JobHunting版 - find kth element in n*n sorted matrix
Divid the matrix to 2 by 2. Each are n/2 X n/2
If k<=n*n/4, restrain search to only the top left square
Else if k =>n*n*3/4 restrain search to only the right bottom square
Else restrain search to top right and bottom left square
This way you cut it at least to half size each time
T(n) = 2T(n/2) O(1)
So T(n) = O(nlogn)

O(n) is doable. But I need O(n lgn) and the code.O(n) algorithmhttp://www.cse.yorku.ca/~........
h********e
发帖数: 1972
26
来自主题: JobHunting版 - 说一题恶心题怎么用nlog n来解。
一般面试不会见到这种东西的。权当娱乐吧。
P1:两个sorted数组,每个数组选一个数,相加。求第k大的和。
P2:一个n*n的矩阵,行和列都是sorted的,求第k大数。假设是从左到右递增,从上到
下递增。
P1是P2的特例。
这个题目O(n^2)是最直接的解法。然后有个O(k logn)的用堆来做,稍微tricky一些。
下面说下n logn的怎么搞出来。
首先想到的是套median的算法。比如一开始拿矩阵中心的那个数,say q 出来。从右上
开始往左下 能用O(n)的时间找出一条分界线, 这条分界线是单调的。使得这条线以上
的数比q小,下的数比q大。然后扔掉不对的那一半递归。第一次这么扔能扔掉至少1/4
的矩阵。问题来了,第二次继续在剩下的里面怎么做。
剩下的是神马。。是n 个row。每个row大小都不一样。目标是在这堆row里面扔掉至少1
/4. 这时候,每个row 可以找出一个median来。然后一般的做法找medians的median。
但是在这里行不通,因为有的row size比较小,这么做不能保证每次扔掉1/4. 必须修
正算法。要找weighted median。这... 阅读全帖
p**f
发帖数: 3549
27
来自主题: Programming版 - an+b复杂度为什么是O(n^2), Θ(n)?
我知道大O和Θ的区别,Θ是上下夹趋近,大O只是上趋近。Θ(n)好理解。
可是为什么线性函数an+b的复杂度是O(n^2),而不是O(n)?
就算是根据定义:
O(g(n)) = {f(n): 存在一个正数c, n0使得 0<=f(n)<=cg(n), for n>=n0}
对于任意an+b(假设a, b都是正数), 我取c=(a+1), n0=(b+1),就可以满足上述不等式
吧,
即:0 <= an+b <= (a+1)n, for n>=(b+1).
所以还是O(n)啊。
百思不得其姐。求指点。
d*********1
发帖数: 25
28
连续扔n次硬币,只有最后3次是连续head的概率?(ie 前n-3次中没有出现过连续3次h
ead)
if (n>4)
let m=n-4 // minus 4 is because the last 4th one must be 0
then we have total sample 2^n;
the total 3 heads within 2^m samples will be:
h(m)=(m-2)*2^(m-3)-(m-2-1) //note m-2=Cm-2^1 (with subscript m-2)
so the non 3 head number is: 2^m-h(m)
we get the P=(2^m-h(m))/2^n;
when n==4 --> P=1/2^4
n is impossible <=3
so .......
p=1/16 (n=4)
P=(2^m-h(m))/2^n; (n>4,m=n-4)
H****h
发帖数: 1037
29
来自主题: Science版 - 加强N皇后问题
除了是N皇后问题的解外,还要求满足:将任意前m行平移到后N-m行之后,
仍然是N皇后问题的解;等价地,将前m列平移到和后N-m列之后仍是解。
判断方法是:设第n行皇后的位置是An,则当n不等于m时,An不等于Am;
|An-Am|不等于|n-m|;|An-Am|+|n-m|不等于N。
谁有空编个程序算算,除一外,N最小是几,加强N皇后问题有解。
N=8时情况如何?最好再给出几个例子来。
I**A
发帖数: 2345
30
来自主题: JobHunting版 - in what case O(n*2) is better than O(n).
Give some scenarios where you might favor O(n^2) algorithm over a O(nlg(n))
i. If O(nlg(n)) requires space, while O(n^2) doesn’t
ii. If O(nlg(n)) is difficult to understand and to implement, while O(n^2
) is easier
iii. If O(n^2) has a general running time less than O(nlg(n)) instead
iv. If O(n^2) is easy to serialize, while O(nlg(n)) not
a***y
发帖数: 50
31
俺写了一个, 没有测试过只有1, 2, 或者0 的情况...
请高手指正...
思路就是维护了三个指针p0, p1, p2, 分别指向了数组index最小的0, 1, 2值所在位置,
然后遍历的过程中,不断swap(值和指针同时swap), 复杂度为O(n), 常数空间.
请高手们多指正了!
#include
#include
using namespace std;
class MITbbSolver
{
public:
MITbbSolver() {}
virtual ~MITbbSolver() {}
public:
void swap_pv(int* &p1, int* &p2) {
int tmp = *p1;
*p1 = *p2;
*p2 = tmp;
int* p = p1;
p1 = p2;
p2 = p;
return;
}
void sort_012_array(int* ... 阅读全帖
A*******8
发帖数: 1453
32
来自主题: WaterWorld版 - pīnyīn wénzì zhēnde nàme bùkān ma?
Shǒuxiān shēngmíng,wǒ hái búshì gǔchuī pīnyīn wénzì. Yīnwéi
zhèyàng zuò yídìng huì bèi hěnduō rén mà. Wǒ wúyì tiǎoqǐ rè
nhé zhēngduān.
Dànshì, wǒ shì juéde xuéxí hànzì de zīyuán xiāohào díquè fē
icháng dà. Hànzì díquè shì yígè hěn dútè de xìtǒng, zìrán y
ǒu tā de měi hé yòngchù. Dànshì duìyú pǔjí zhīshi de mùdì lá
ishuō, sìhū yǒu yìdiǎnr bú gòu jīngjì.
Zhuāngzǐ zǎo jiù shuōguò: yán suǒyǐ zài yì,dé yì ér wàng yán
. Suǒyǐ, shuōhuà de zuòyòng zàiyú biǎodá hé chuándá yìyi. Wé
nzì shì yònglái jìlù yǔ
b******y
发帖数: 9224
33
jdk里面的源程序如下:
public int nextInt(int n) {
if (n<=0)
throw new IllegalArgumentException("n must be positive");
if ((n & -n) == n) // i.e., n is a power of 2
return (int)((n * (long)next(31)) >> 31);
int bits, val;
do {
bits = next(31);
val = bits % n;
} while(bits - val + (n-1) < 0);
return val;
}
读不懂的地方是while(bits - val + (n-1) < 0);
为啥要这样判断呢?
o****e
发帖数: 80
34
【 以下文字转载自 BrainTeaser 讨论区 】
发信人: ogtree (好好努力), 信区: BrainTeaser
标 题: Re: 还是扔鸡蛋,N层楼M个鸡蛋咋办啊
发信站: BBS 未名空间站 (Thu Jul 8 16:19:07 2010, 美东)
i think for the case of 3 eggs, should be like this
start from n-th floor, then try middle floor of n/2-th , then use the 3rd
egg to try either upper half section
or lower half section,
so for the n-th floor, the max try will be (n+2)/2;
then go to the n-2 th floor, the max try will be n/2
and so on
so the sequence will be like this
n, n-2, n-4, n-6, .........
s**********r
发帖数: 8153
35
来自主题: Quant版 - 绿书概率,圆上N点的问题
答案是这样的.
但我是这样想的.
这N个点中,比如i在最边上,于是其他的点(N-1个)在i的一侧并且半圆的概率是1/2^(N-1
). 但它有2侧,所以是2*1/2^(N-1)=1/2^(N-2).
N个点都有可能在最边上,每个概率是1/N, 所以:
N*1/N*1/2^(N-2)=1/2^(N-2).....
我的...哪里出错了?谢谢哦~~

fall
i********y
发帖数: 2263
36
来自主题: Classified版 - [求购]homedepot gift card [email protected]
我想要的物品:
homedepot gift card $250
单张面值:
n/a
可接受的价格(必须明码标价!):
0.9x250
物品新旧要求:
n/a
邮寄方式要求:
code only
买卖双方谁承担邮寄损失(Required if not code only):
n/a
付款方式说明:
non-cc paypal or bill pay
其他补充说明:
n/a
广告的有效期:
till get
物品来源:
n/a
我的联系方式:
mitbbs
二手交易风险自负!请自行验证是否合法和一手卡!:
n
t*********u
发帖数: 26311
37
来自主题: FleaMarket版 - [出售]Citi thank you point TYP [email protected]
二手交易风险自负!请自行验证是否合法和一手卡!:
y
我想卖的物品:
Citi thank you point TYP [email protected]/* */
单张面值:
n/a
可接受价格(必须明码标价!):
@1.3
物品新旧要求:
n/a
邮寄方式要求:
n/a
买卖双方谁承担邮寄损失(Required if not code only):
n/a
付款方式说明:
BoA, non-CC paypal
其他补充说明:
没有prestige premier
广告的有效期:
till gone
物品来源(Required for All Cards!):
Citi ATT
我的联系方式:
BBS Mail
Warranty期限:
n/a
能否证明是合法的一手卡?(Required for All Cards!):
y
state and zip:
n/a
i********y
发帖数: 2263
38
来自主题: FleaMarket版 - [求购]homedepot gift card [email protected]
我想要的物品:
homedepot gift card $250
单张面值:
n/a
可接受的价格(必须明码标价!):
0.9x250
物品新旧要求:
n/a
邮寄方式要求:
code only
买卖双方谁承担邮寄损失(Required if not code only):
n/a
付款方式说明:
non-cc paypal or bill pay
其他补充说明:
n/a
广告的有效期:
till get
物品来源:
n/a
我的联系方式:
mitbbs
二手交易风险自负!请自行验证是否合法和一手卡!:
n
f*******n
发帖数: 12623
39
来自主题: JobHunting版 - 说一题恶心题怎么用nlog n来解。
你弄错了什么东西。如果T(N) = O(\sqrt(N)) + T(3N/4) ,那T(N) = O(\sqrt(N))。
证明:O(\sqrt(N)) + T(3N/4) = O(\sqrt(N)) + O(\sqrt(3N/4)) = O(\sqrt(N)) +
\sqrt(3/4)O(\sqrt(N)) = O(\sqrt(N)) = T(N)
c****p
发帖数: 6474
40
来自主题: JobHunting版 - 按十字题的O(M*N)时间解
3.简单起见,一个格子被直接按中导致的0-1翻转称为主翻转,和它同行同列的翻转导致
的翻转称为副翻转。那么需要找到一个将主翻转和副翻转区分开来的办法。可以考虑异
或。
4.对于给定图案中的任意一点x,y,可以把它所在的行和列的所有元素相异或。对于M+N
为偶的,若结果为1,则说明该点被按过;对于M+N为奇数的,若结果为0,则说明该点被
按过。
举个例子(我自己写的一个生成图案的函数)
A是图案,D是被按过的键,也即我们要找的解
>> [A,D] = gen_pad(4,4,.2)
A =
1 0 0 1
1 0 0 1
1 1 1 1
0 0 1 0
D =
0 1 0 0
0 1 0 0
0 0 1 0
0 0 0 0
假设解为S矩阵,我们要求出S=D
假设左上角元素为A[1,1],则
S[1,1]=xor(A[1,... 阅读全帖
z********i
发帖数: 568
41
来自主题: JobHunting版 - 按十字题的O(M*N)时间解
以前一个ID给了一个漂亮的解发,怎么不见了? 概述如下:
let x_{ij} be the number of pressing/clicking at position (i,j), m_{ij} be
the original input element at (i,j), n_{ij} be the final element after all
pressing/clicking.
1. x_{ij}=R_i+C_j-2x_{ij}+m_{ij}-n{ij}=R_i+C_j+m_{ij}-n{ij} mod 2.
Queistion: how to get R_i(the summation of x_{ij} at row i)and C_j(the
summation of x_{ij} at column j)?
Answer: simply sum x_{ij} for 1<=j 2. R_i=nR_i+X+summation of(m_{ij}-n_{ij}) mod 2 at row i.
where X is the summation o... 阅读全帖
d*k
发帖数: 207
42
来自主题: JobHunting版 - leetcode N-Queens II 我的c++要400多毫秒
请问这正常吗?是不是我的算法还不够好?
我用的方法是dfs,逐行枚举能够放下皇后的位置,对于每个位置,需要O(1)的时间判
断是否能够放下皇后。没有其他剪枝。更新buffer是把当前解存下来,是为了做N-
Queens时候用的。代码如下。
class Solution {
public:
void search(int row, int pos, int* buffer, bool* taken, bool* diag_left_
taken, bool* diag_right_taken, int* count, int row_num) {
if (row == row_num) {
*count += 1;
return;
}

if (pos == row_num) {
return;
}

int diag_left = pos - row + row_num;
int di... 阅读全帖
u***8
发帖数: 1581
43
来自主题: JobHunting版 - 面试题,min steps to reduce n to 1
这个是dp的问题吧。
给一个数字n,用减1,or 能整除2 就整除,能整除3就整除,3种方法,将n 减到1。
求最少的steps。
好像简单的。
我给了个算法。最后15分钟,有点赶。leetcode有类似题目么?不记得了。貌似有个变
形的题目,类似。
public int getMinSteps(int n) { // 1 ---> n , better way to do from n
-->1
int[] arr = new int[n]; arr[i] denotes how many steps to get value
i+1;
//dynamic programming to refresh the array;
//arr[i] denotes min steps to reach 1+i, so 1 =1 , 0 steps needed.
arr[0] = 0;
arr[1] = 1;
for (int i = 2; i < n ; i++) ... 阅读全帖
a*******n
发帖数: 64
44
题很简单,就是从n个数(1到n)里挑出k个数,return所有组合可能。我觉得下面有个
地方可以优化成n-depth+1,就不需要再往后面走了,因为这个解不成立,但是OJ上说
是错的,想了下竟然没想明白。有谁指点一下?
class Solution {
public:
void addComb(int n, int depth, int begin, vector>& res,
vector& solution){
if (depth==0){
res.push_back(solution);
}
for (int i = begin; i <= (n-depth+1); ++i){// i <= n is correct, why
n-depth+1 doesn't work?
solution.push_back(i);
addComb(n, depth-1, i+1, res, solution);
... 阅读全帖
I****A
发帖数: 608
45
来自主题: Midlife版 - 看了来美N年
大家热火朝天的讨论来美N年,生了N个小孩,买了N辆或新或旧的车,N年后拿绿卡,N
年后毕业,N年N K工资,全美旅游N次。
感觉大家的路都一样啊。 N大一点,小一点而已,真牛的不多,真惨的没有。
过着和大家一样的生活,N不大不小,生活又开始飞扬了。
s*****c
发帖数: 36
46
来自主题: Database版 - 讨论:在SELECT中限制TOP N条纪录
Hi, everyone:
本贴讨论SELECT TOP N问题.
现在正在一家计算机公司兼职,开发ASP应用. 在最近的一个商业
项目里有这样一个需求:用户在查询时,只需要按照某(些)列排序后TO
P 20的纪录. SQL SERVER 7很好地支持了TOP N 操作,但考虑到系统
移植问题, 我又考虑在其他几个主流DBMSs中如何实现. 鉴于只有DB2
UDB 7,ORACLE 8i,SQL SERVER 7,本贴仅讨论这三个DBMS.
简单地说,TOP N问题就是:在SELECT中,仅选择按照某(些)列排序
后TOP N的纪录. 考虑到等值问题,又可以分为两种: 一是仅仅返回N
条纪录(M 1), 二是还包括所有于第N条等值的纪录(M 2). 当然最内
层的子查询也可以有其他的子句, 或者TOP N也可以应用在没有ORDER
BY的情况下,这样更简单.
1. SQL SERVER 7: 用 TOP N (WITH TIES)
M1:
SELECT TOP N * FROM MYTABLE ORDER BY ORD_COL;
M2:
SELECT TOP N
Q***5
发帖数: 994
47
This can be proved:
For any epsilon >0, there exists K, such that \sum_K^\infty i*P(i)<\epsilon
Let N big enough, such that K/N<\epsilon.
Now, for any n>N,
\sum_1^n i*P(i)/n <= (\sum_1^(K-1) K*P(i)+ n*\sum_K^n P(i))/n epsilon< 2*\epsilon
b***k
发帖数: 2673
48
☆─────────────────────────────────────☆
blueski (蓝天白云) 于 (Mon Apr 7 20:14:14 2008) 提到:
连续扔n次硬币,只有最后3次是连续head的概率?(ie 前n-3次中没有出现过连续3次h
ead)
☆─────────────────────────────────────☆
jejune (孑孓) 于 (Tue Apr 8 11:39:16 2008) 提到:
define "triple Fibonacci number" as
tf(1)=tf(2)=1, tf(3)=2,
tf(n)=tf(n-1)+tf(n-2)+tf(n-3), n>3
P(连续扔n次硬币,只有最后3次连续是正面的概率)= tf(n-2)/2^n
☆─────────────────────────────────────☆
seeking (恣意妄为) 于 (Tue Apr 8 12:03:00 2008) 提到:
这个是怎么来的?

☆────────────────────────────
l**i
发帖数: 5
49
来自主题: Science版 - Re: help: the approximation of n!
n!=(2*pi*n)^(1/2)*(n/e)^n*f(n)
where f(n) is an asymptotic series with
the leading coefficient 1,
f(n)=1+1/(12*n)+1/(288*n*n)+...
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)